import request from "@/utils/request";
import {BaseColumnMatchVO} from "./types";

/**
 * 保存基础字段配置
 *
 * @param data
 */
export function saveColumnMatch(data: BaseColumnMatchVO) {
	return request({
		url: "/api/v1/baseColumnMatch",
		method: "post",
		data: data,
	});
}

/**
 * 获取基础字段配置列表
 *
 * @param queryParams
 */
export function getBaseColumnList(platformKey: string) {
	return request({
		url: '/api/v1/baseColumnMatch/' + platformKey + '/form',
		method: 'get'
	});
}

/**
 * 删除基础字段配置
 *
 * @param ids
 */
export function deleteBaseColumn(ids: number) {
	return request({
		url: '/api/v1/baseColumnMatch/' + ids,
		method: 'delete'
	});
}

/**
 * 检查是否配置到关联单号和业务日期
 *
 * @param queryParams
 */
export function check(platformKey: string) {
	return request({
		url: '/api/v1/baseColumnMatch/check/' + platformKey,
		method: 'get'
	});
}

/**
 * 导入记账项目
 *
 * @param file
 * @param platformKey
 */
export function billImport(file: File, platformKey: string) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/baseColumnMatch/billConfigImport/'+platformKey,
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}

/**
 * 导出天猫账单配置
 *
 * @returns
 */
export function billExport(platformKey: string) {
	return request({
		url: '/api/v1/baseColumnMatch/billConfigExport/'+platformKey,
		method: 'get',
		responseType: 'arraybuffer'
	});
}

